#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
//execl命令使用


int main()
{
    pid_t pid = fork();
    
     if(pid<0)
     {
       perror("fork");
       exit(1);
     }

     if(pid ==0)
     {
        //执行外部命令
        execl("/usr/bin/ps","ps","-o","pid,ppid,pgrp,tpgid",(char*)NULL);
     }
     else 
     {
        //父进程等待
        wait(NULL);
     }

    return EXIT_SUCCESS;
}